#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main() {
    int randomNumber, guess, numberOfTries = 0;
    srand(time(NULL)); // Seed the random number generator
    randomNumber = rand() % 100 + 1; // Generate a random number between 1 and 100
    printf("欢迎来到猜数字游戏!\n");
    printf("选一个1到100之间的数字\n");
    do {
        printf("请输入你猜的数字: ");
        scanf("%d", &guess);
        numberOfTries++;
        if (guess > randomNumber) {
            printf("大了，请重新尝试\n");
        } else if (guess < randomNumber) {
            printf("小了，请重新尝试.\n");
        } else {
            printf("恭喜你猜对了! 一共尝试了%d次\n", numberOfTries);
        }
    } while (guess != randomNumber);

    return 0;
}

